//
//
//
//
//
//
//
//
//
//
import yearButton from './yearButton'
export default {
props: {
maxDate: {
type: Date
},
minDate: {
type: Date
},
selectedDate: {
type: Date
}
},
computed: {
years () {
const minYear = this.minDate.getFullYear()
const maxYear = this.maxDate.getFullYear()
const years = []
for (let year = minYear; year <= maxYear; year++) {
years.push(year)
}
return years
}
},
methods: {
handleClick (year) {
this.$emit('change', year)
},
scrollToSelectedYear (yearButtonNode) {
const container = this.$refs.container
const containerHeight = container.clientHeight
const yearButtonNodeHeight = yearButtonNode.clientHeight || 32
const scrollYOffset = (yearButtonNode.offsetTop + yearButtonNodeHeight / 2) - containerHeight / 2
container.scrollTop = scrollYOffset
}
},
components: {
'year-button': yearButton
}
}
|